<?php

namespace app\datalog;

class ErrorLog extends StorageDatalogBase
{
    // 日志名称
    protected $name = 'error';

    // 请求日志单独存放
    protected $logPath = 'datalogs/error';

    protected $formatter = 'json';

    public function addThrowable($error)
    {
        $params = [
            'type'  => 'error',
            'class' => get_class($error),
            'code'  => $error->getCode(),
            'file'  => $error->getFile(),
            'line'  => $error->getLine(),
            'msg'   => $error->getMessage(),
            // 'trace' => $error->getTrace(),
        ];

        $this->log($params);
    }
}
